﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Data.Common;
using Mocola.BLL;
using Mocola.Model;

namespace Mocola.Net.Web.ajax
{
    public partial class GetFile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                string ID = Request.QueryString["id"];
                using (IDataReader reader = Databases.MocolaNet.Select(Moc_FilesInfo.Moc_Files,
                   Moc_FilesInfo.Moc_Files.ID,
                   Moc_FilesInfo.Moc_Files.Name,
                   Moc_FilesInfo.Moc_Files.WenJianHao,
                   Moc_FilesInfo.Moc_Files.ShenQingHao,
                   Moc_FilesInfo.Moc_Files.JueDingHao,
                   Moc_FilesInfo.Moc_Files.FaWenRiQi,
                   Moc_FilesInfo.Moc_Files.FaWenDanWei,
                   Moc_FilesInfo.Moc_Files.ShuLiang,
                   Moc_FilesInfo.Moc_Files.ZaiTi,
                   Moc_FilesInfo.Moc_Files.CaiZhi,
                   Moc_FilesInfo.Moc_Files.MiJi,
                   Moc_FilesInfo.Moc_Files.BaoGuanQiXian,
                   Moc_FilesInfo.Moc_Files.ZhuangTai,
                   Moc_FilesInfo.Moc_Files.FaQiBuMen,
                   Moc_FilesInfo.Moc_Files.YiJiaoRen,
                   Moc_FilesInfo.Moc_Files.JieShouRen,
                   Moc_FilesInfo.Moc_Files.JieShouRiQi,
                   Moc_FilesInfo.Moc_Files.BeiZhu,
                   Moc_FilesInfo.Moc_Files.Eid,
                   Moc_FilesInfo.Moc_Files.Tid)
                   .Where(Moc_FilesInfo.Moc_Files.ID == Convert.ToInt32(ID))
                   .ToDataReader())
                {
                    string Datastring = string.Empty;
                    Response.Write("{\"Moc_Files\":[ {");

                    while (reader.Read())
                    {
                        int ID2 = reader.GetInt32(0);
                        string Name = reader.GetString(1);
                        string WenJianHao = reader.GetString(2);
                        string ShenQingHao = reader.GetString(3);
                        string JueDingHao = reader.GetString(4);
                        string FaWenRiQi = reader.GetString(5);
                        string FaWenDanWei = reader.GetString(6);
                        string ShuLiang = reader.GetString(7);
                        int ZaiTi = reader.GetInt32(8);
                        int CaiZhi = reader.GetInt32(9);
                        int MiJi = reader.GetInt32(10);
                        int BaoGuanQiXian = reader.GetInt32(11);
                        int ZhuangTai = reader.GetInt32(12);
                        string FaQiBuMen = (!reader.IsDBNull(13)) ? reader.GetString(17) : string.Empty;
                        string YiJiaoRen = (!reader.IsDBNull(14)) ? reader.GetString(18) : string.Empty;
                        string JiShouRen = (!reader.IsDBNull(15)) ? reader.GetString(19) : string.Empty;
                        string JiShouRiQi = reader.GetString(16);
                        string BeiZhu = reader.GetString(17);
                        int Eid = reader.GetInt32(18);
                        int Tid = reader.GetInt32(19);

                        Response.Write("\"ID\":" + ID + ",");
                        Response.Write("\"Name\":\"" + Name + "\",");
                        Response.Write("\"WenJianHao\":\"" + WenJianHao + "\",");
                        Response.Write("\"ShenQingHao\":\"" + ShenQingHao + "\",");
                        Response.Write("\"JueDingHao\":\"" + JueDingHao + "\",");
                        Response.Write("\"FaWenRiQi\":\"" + FaWenRiQi + "\",");
                        Response.Write("\"FaWenDanWei\":\"" + FaWenDanWei + "\",");
                        Response.Write("\"ShuLiang\":\"" + ShuLiang + "\",");
                        Response.Write("\"ZaiTi\":" + ZaiTi + ",");
                        Response.Write("\"CaiZhi\":" + CaiZhi + ",");
                        Response.Write("\"MiJi\":" + MiJi + ",");
                        Response.Write("\"BaoGuanQiXian\":" + BaoGuanQiXian + ",");
                        Response.Write("\"ZhuangTai\":" + ZhuangTai + ",");
                        Response.Write("\"FaQiBuMen\":\"" + FaQiBuMen + "\",");
                        Response.Write("\"YiJiaoRen\":\"" + YiJiaoRen + "\",");
                        Response.Write("\"JiShouRen\":\"" + JiShouRen + "\",");
                        Response.Write("\"JiShouRiQi\":\"" + JiShouRiQi + "\",");
                        Response.Write("\"BeiZhu\":\"" + BeiZhu + "\",");
                        Response.Write("\"Eid\":" + Eid + ",");
                        Response.Write("\"Tid\":" + Tid);
                    }

                    Response.Write("} ]}");
                }
            }
        }
    }
}
